diff --git a/.gitignore b/.gitignore
index 46ccd55..5fc64ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,8 +39,7 @@ Module.symvers
 patches-*
 
 # quilt's files
-patches
-series
+.pc
 
 # cscope files
 cscope.*
diff --git a/debian/changelog b/debian/changelog
index 63eb241..450e99a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+qtmoko (36-1+pini) unstable; urgency=low
+
+  * Debian cross-building support
+
+ -- Gilles Filippini <pini@debian.org>  Sat, 03 Dec 2011 17:22:21 +0100
+
 qtmoko (36-1) unstable; urgency=low
 
   * Can use freesmartphone.org stack as modem backend
diff --git a/debian/control b/debian/control
index a79f77c..fac98e1 100644
--- a/debian/control
+++ b/debian/control
@@ -2,13 +2,13 @@ Source: qtmoko
 Section: comm
 Priority: optional
 Maintainer: Radek Polak <psonek2@seznam.cz>
-Build-Depends: debhelper (>= 7.0.50~)
-Standards-Version: 3.8.4
+Build-Depends: debhelper (>= 7.0.50~), libxext-dev, libasound2-dev, libdbus-1-dev, libssl-dev, libts-dev, libbluetooth-dev, libxtst-dev, libpng12-dev, libjpeg8-dev, libtiff4-dev, libmng-dev
+Standards-Version: 3.9.2
 Homepage: http://www.qtmoko.org
 Vcs-Git: git://github.com/radekp/qtmoko.git
 Vcs-Browser: https://github.com/radekp/qtmoko
 
 Package: qtmoko
 Architecture: any
-Depends: 
+Depends: ${misc:Depends}, ${shlibs:Depends}, bluez-alsa, ttf-dejavu, sqlite3, psmisc, alsa-utils
 Description: QtMoko is phone environment
diff --git a/debian/linux-debian-g++/qmake.conf b/debian/linux-debian-g++/qmake.conf
new file mode 100644
index 0000000..b041bc2
--- /dev/null
+++ b/debian/linux-debian-g++/qmake.conf
@@ -0,0 +1,85 @@
+#
+# qmake configuration for linux-g++ using the arm-linux-g++ crosscompiler
+#
+
+MAKEFILE_GENERATOR	= UNIX
+TEMPLATE		= app
+CONFIG			+= qt warn_on release link_prl
+QT                      += core gui network
+QMAKE_INCREMENTAL_STYLE = sublib
+
+QMAKE_CC		= @CROSS_CC@
+QMAKE_LEX		= flex
+QMAKE_LEXFLAGS		=
+QMAKE_YACC		= yacc
+QMAKE_YACCFLAGS		= -d
+QMAKE_CFLAGS		= -pipe @CROSS_CFLAGS@
+QMAKE_CFLAGS_WARN_ON	= -Wall -W
+QMAKE_CFLAGS_WARN_OFF	=
+QMAKE_CFLAGS_RELEASE	= 
+# -mfpu=vfp -mfloat-abi=softfp
+QMAKE_CFLAGS_DEBUG	= 
+QMAKE_CFLAGS_SHLIB	= -fPIC
+QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses
+QMAKE_CFLAGS_THREAD	= -D_REENTRANT
+QMAKE_CFLAGS_HIDESYMS   = -fvisibility=hidden
+
+QMAKE_CXX		= @CROSS_CXX@
+QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS -DQT_QWS_FICGTA01 -fno-exceptions -fno-rtti
+QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
+QMAKE_CXXFLAGS_WARN_OFF	= $$QMAKE_CFLAGS_WARN_OFF
+QMAKE_CXXFLAGS_RELEASE	= $$QMAKE_CFLAGS_RELEASE
+QMAKE_CXXFLAGS_DEBUG	= $$QMAKE_CFLAGS_DEBUG
+QMAKE_CXXFLAGS_SHLIB	= $$QMAKE_CFLAGS_SHLIB
+QMAKE_CXXFLAGS_YACC	= $$QMAKE_CFLAGS_YACC
+QMAKE_CXXFLAGS_THREAD	= $$QMAKE_CFLAGS_THREAD
+QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
+
+QMAKE_INCDIR		= @CROSS_INCDIR@
+QMAKE_LIBDIR		= @CROSS_LIBDIR@
+QMAKE_INCDIR_X11	= 
+QMAKE_LIBDIR_X11	= 
+QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]
+QMAKE_LIBDIR_QT		= $$[QT_INSTALL_LIBS]
+QMAKE_INCDIR_OPENGL	= 
+QMAKE_LIBDIR_OPENGL	= 
+
+QMAKE_LINK		= @CROSS_CXX@
+QMAKE_LINK_SHLIB	= @CROSS_CXX@
+QMAKE_LFLAGS		= @CROSS_LDFLAGS@
+QMAKE_LFLAGS_RELEASE	=
+QMAKE_LFLAGS_DEBUG	=
+QMAKE_LFLAGS_SHLIB      = -shared
+QMAKE_LFLAGS_PLUGIN     = $$QMAKE_LFLAGS_SHLIB
+QMAKE_LFLAGS_SONAME     = -Wl,-soname,
+QMAKE_LFLAGS_THREAD     =
+QMAKE_RPATH             = -Wl,-rpath-link,
+
+QMAKE_LIBS		= 
+QMAKE_LIBS_DYNLOAD      = -ldl
+QMAKE_LIBS_X11		= 
+QMAKE_LIBS_X11SM	= -lSM -lICE
+QMAKE_LIBS_QT		= -lqte
+QMAKE_LIBS_QT_THREAD    = -lqte-mt
+QMAKE_LIBS_QT_OPENGL	= -lqgl
+QMAKE_LIBS_QTOPIA	= -lqpe -lqtopia
+QMAKE_LIBS_THREAD       = -lpthread
+
+QMAKE_MOC		= $$[QT_INSTALL_BINS]/moc
+QMAKE_UIC		= $$[QT_INSTALL_BINS]/uic
+
+QMAKE_AR		= ar cqs
+QMAKE_RANLIB		=
+
+QMAKE_TAR		= tar -cf
+QMAKE_GZIP		= gzip -9f
+
+QMAKE_COPY		= cp -f
+QMAKE_MOVE		= mv -f
+QMAKE_DEL_FILE		= rm -f
+QMAKE_DEL_DIR		= rmdir
+QMAKE_CHK_DIR_EXISTS	= test -d
+QMAKE_MKDIR		= mkdir -p
+QMAKE_STRIP             = strip
+QMAKE_STRIPFLAGS_LIB   += --strip-unneeded
+load(qt_config)
diff --git a/debian/linux-debian-g++/qplatformdefs.h b/debian/linux-debian-g++/qplatformdefs.h
new file mode 100644
index 0000000..ce7bea4
--- /dev/null
+++ b/debian/linux-debian-g++/qplatformdefs.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** This file is part of the Qt Extended Opensource Package.
+**
+** Copyright (C) 2009 Trolltech ASA.
+**
+** Contact: Qt Extended Information (info@qtextended.org)
+**
+** This file may be used under the terms of the GNU General Public License
+** version 2.0 as published by the Free Software Foundation and appearing
+** in the file LICENSE.GPL included in the packaging of this file.
+**
+** Please review the following information to ensure GNU General Public
+** Licensing requirements will be met:
+**     http://www.fsf.org/licensing/licenses/info/GPLv2.html.
+**
+**
+****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+// Get Qt defines/settings
+
+#include "qglobal.h"
+
+// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
+
+// 1) need to reset default environment if _BSD_SOURCE is defined
+// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
+// 3) it seems older glibc need this to include the X/Open stuff
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+
+
+// We are hot - unistd.h should have turned on the specific APIs we requested
+
+#include <features.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+#include <dlfcn.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/ipc.h>
+#include <sys/time.h>
+#include <sys/shm.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <netinet/in.h>
+#ifndef QT_NO_IPV6IFNAME
+#include <net/if.h>
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF              struct stat64
+#define QT_STATBUF4TSTAT        struct stat64
+#define QT_STAT                 ::stat64
+#define QT_FSTAT                ::fstat64
+#define QT_LSTAT                ::lstat64
+#define QT_OPEN                 ::open64
+#define QT_TRUNCATE             ::truncate64
+#define QT_FTRUNCATE            ::ftruncate64
+#define QT_LSEEK                ::lseek64
+#else
+#define QT_STATBUF              struct stat
+#define QT_STATBUF4TSTAT        struct stat
+#define QT_STAT                 ::stat
+#define QT_FSTAT                ::fstat
+#define QT_LSTAT                ::lstat
+#define QT_OPEN                 ::open
+#define QT_TRUNCATE             ::truncate
+#define QT_FTRUNCATE            ::ftruncate
+#define QT_LSEEK                ::lseek
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_FOPEN                ::fopen64
+#define QT_FSEEK                ::fseeko64
+#define QT_FTELL                ::ftello64
+#define QT_FGETPOS              ::fgetpos64
+#define QT_FSETPOS              ::fsetpos64
+#define QT_MMAP                 ::mmap64
+#define QT_FPOS_T               fpos64_t
+#define QT_OFF_T                off64_t
+#else
+#define QT_FOPEN                ::fopen
+#define QT_FSEEK                ::fseek
+#define QT_FTELL                ::ftell
+#define QT_FGETPOS              ::fgetpos
+#define QT_FSETPOS              ::fsetpos
+#define QT_MMAP                 ::mmap
+#define QT_FPOS_T               fpos_t
+#define QT_OFF_T                long
+#endif
+
+#define QT_STAT_REG		S_IFREG
+#define QT_STAT_DIR		S_IFDIR
+#define QT_STAT_MASK		S_IFMT
+#define QT_STAT_LNK		S_IFLNK
+#define QT_SOCKET_CONNECT	::connect
+#define QT_SOCKET_BIND		::bind
+#define QT_SOCKET_BIND		::bind
+#define QT_FILENO		fileno
+#define QT_CLOSE		::close
+#define QT_READ			::read
+#define QT_WRITE		::write
+#define QT_ACCESS		::access
+#define QT_GETCWD		::getcwd
+#define QT_CHDIR		::chdir
+#define QT_MKDIR		::mkdir
+#define QT_RMDIR		::rmdir
+#define QT_OPEN_LARGEFILE       O_LARGEFILE
+#define QT_OPEN_RDONLY		O_RDONLY
+#define QT_OPEN_WRONLY		O_WRONLY
+#define QT_OPEN_RDWR		O_RDWR
+#define QT_OPEN_CREAT		O_CREAT
+#define QT_OPEN_TRUNC		O_TRUNC
+#define QT_OPEN_APPEND		O_APPEND
+
+#define QT_SIGNAL_RETTYPE	void
+#define QT_SIGNAL_ARGS		int
+#define QT_SIGNAL_IGNORE	SIG_IGN
+
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+#define QT_SOCKLEN_T		socklen_t
+#else
+#define QT_SOCKLEN_T		int
+#endif
+
+#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+#define QT_SNPRINTF		::snprintf
+#define QT_VSNPRINTF		::vsnprintf
+#endif
+
+#define QT_QLOCALE_USES_FCVT
+
+#endif // QPLATFORMDEFS_H
diff --git a/debian/patches/alsa-scenarios.patch b/debian/patches/alsa-scenarios.patch
new file mode 100644
index 0000000..c8b0e30
--- /dev/null
+++ b/debian/patches/alsa-scenarios.patch
@@ -0,0 +1,68 @@
+Index: qtmoko/devices/neo/server/neovolumeservice.cpp
+===================================================================
+--- qtmoko.orig/devices/neo/server/neovolumeservice.cpp	2011-11-01 11:50:39.656731994 +0100
++++ qtmoko/devices/neo/server/neovolumeservice.cpp	2011-12-01 21:30:21.850417734 +0100
+@@ -269,8 +269,8 @@
+         m_mode = "gsmbluetooth";
+ 
+     QString confDir;
+-    if (QDir("/usr/share/openmoko/scenarios").exists())
+-        confDir="/usr/share/openmoko/scenarios/";
++    if (QDir("/opt/qtmoko/etc/alsa-scenarios").exists())
++        confDir="/opt/qtmoko/etc/alsa-scenarios/";
+     else
+         confDir="/etc/";
+ 
+Index: qtmoko/devices/neo/src/plugins/audiohardware/neo/neoaudioplugin.cpp
+===================================================================
+--- qtmoko.orig/devices/neo/src/plugins/audiohardware/neo/neoaudioplugin.cpp	2011-11-01 11:50:39.664732040 +0100
++++ qtmoko/devices/neo/src/plugins/audiohardware/neo/neoaudioplugin.cpp	2011-12-01 21:29:47.990252199 +0100
+@@ -80,7 +80,7 @@
+ 
+     QStringList args;
+     args.append("-f");
+-    args.append("/usr/share/openmoko/scenarios/" + mode + ".state");
++    args.append("/opt/qtmoko/etc/alsa-scenarios/" + mode + ".state");
+     args.append("restore");
+ 
+     QProcess p;
+@@ -90,7 +90,7 @@
+     int result = p.exitCode();
+ 
+     if (result == 0)
+-        qLog(AudioState) << "setAudioScenario(); using"<< QString( "/usr/share/openmoko/scenarios/%1.state").arg(mode);
++        qLog(AudioState) << "setAudioScenario(); using"<< QString( "/opt/qtmoko/etc/alsa-scenarios/%1.state").arg(mode);
+     else
+         qLog(AudioState)<< QString("Setting audio mode to: %1 failed").arg(mode);
+ 
+Index: qtmoko/src/3rdparty/applications/neocontrol/neocontrol.cpp
+===================================================================
+--- qtmoko.orig/src/3rdparty/applications/neocontrol/neocontrol.cpp	2011-11-18 22:02:59.424941997 +0100
++++ qtmoko/src/3rdparty/applications/neocontrol/neocontrol.cpp	2011-12-01 21:29:30.966168975 +0100
+@@ -112,7 +112,7 @@
+ {
+     if(screen == ScreenMixer)
+     {
+-        system("alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state store");
++        system("alsactl -f /opt/qtmoko/etc/alsa-scenarios/gsmhandset.state store");
+     }
+ }
+ 
+@@ -184,7 +184,7 @@
+ 
+ int NeoControl::openAlsaMixer()
+ {
+-    system("alsactl -f /usr/share/openmoko/scenarios/gsmhandset.state restore");
++    system("alsactl -f /opt/qtmoko/etc/alsa-scenarios/gsmhandset.state restore");
+ 
+     int ret = 0;
+     QString text(tr("Call volume settings\n\n"));
+@@ -226,7 +226,7 @@
+         mixerFd = NULL;
+     }
+ 
+-    system("alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore");
++    system("alsactl -f /opt/qtmoko/etc/alsa-scenarios/stereoout.state restore");
+ }
+ 
+ void NeoControl::updateMixer()
diff --git a/debian/patches/format-not-a-string-literal-and-no-format-arguments.patch b/debian/patches/format-not-a-string-literal-and-no-format-arguments.patch
new file mode 100644
index 0000000..4af0925
--- /dev/null
+++ b/debian/patches/format-not-a-string-literal-and-no-format-arguments.patch
@@ -0,0 +1,250 @@
+Index: qtmoko/src/libraries/qtopiabase/qmemoryfile_unix.cpp
+===================================================================
+--- qtmoko.orig/src/libraries/qtopiabase/qmemoryfile_unix.cpp	2011-10-25 22:33:31.000000000 +0200
++++ qtmoko/src/libraries/qtopiabase/qmemoryfile_unix.cpp	2011-10-25 22:34:23.000000000 +0200
+@@ -135,7 +135,7 @@
+             shmKey = st.st_ino;
+             ::close(f);
+         }else{
+-            qWarning(QString("QMemoryFile result: %1").arg(strerror(errno)).toLatin1().constData());
++            qWarning("%s", QString("QMemoryFile result: %1").arg(strerror(errno)).toLatin1().constData());
+             qWarning("QMemoryfile: Unable to create shared key via id file");
+             return data;
+         }
+@@ -173,7 +173,7 @@
+                 // attach to previously created shared memory
+                 block = (char*)shmat(shmId, NULL, shmAtFlag );
+                 if (block == (void*)-1)
+-                  qWarning(QString("QMemoryFile : %1").arg(strerror(errno)).toLatin1().constData());
++                  qWarning("%s", QString("QMemoryFile : %1").arg(strerror(errno)).toLatin1().constData());
+             }
+ 
+             if (block != NULL){
+@@ -219,7 +219,7 @@
+                 //f = ::open(fileName.toLocal8Bit(), fileMode | O_CREAT);
+ 
+                 if ((::lseek(f, size, SEEK_SET) == -1) || (::write(f, "", 1) == -1)){
+-                  qWarning(QString("QMemoryFile result: %1").arg(strerror(errno)).toLatin1().constData());
++                  qWarning("%s", QString("QMemoryFile result: %1").arg(strerror(errno)).toLatin1().constData());
+                   qWarning("QMemoryFile: Unable to initialize new file");
+                 }else
+                   lseek(f, 0L, SEEK_SET);
+Index: qtmoko/src/libraries/qtopiabase/qexpressionevaluator.cpp
+===================================================================
+--- qtmoko.orig/src/libraries/qtopiabase/qexpressionevaluator.cpp	2011-10-25 22:35:17.000000000 +0200
++++ qtmoko/src/libraries/qtopiabase/qexpressionevaluator.cpp	2011-10-25 22:35:28.000000000 +0200
+@@ -1228,7 +1228,7 @@
+                     n->returnType = ExpressionToken::Integer;
+                     // else runtime coercion
+                 } else {
+-                    qFatal(QString("Unhandled combination of operands '%1' and '%2' for equality operator '%3'").arg(ExpressionToken::typeToName(leftChild->returnType)).arg(ExpressionToken::typeToName(rightChild->returnType)).arg(ExpressionToken::typeToName(node->token.type)).toAscii().data());
++                    qFatal("%s", QString("Unhandled combination of operands '%1' and '%2' for equality operator '%3'").arg(ExpressionToken::typeToName(leftChild->returnType)).arg(ExpressionToken::typeToName(rightChild->returnType)).arg(ExpressionToken::typeToName(node->token.type)).toAscii().data());
+                 }
+                 break;
+             }
+Index: qtmoko/src/libraries/qtopia/qtopiaapplication.cpp
+===================================================================
+--- qtmoko.orig/src/libraries/qtopia/qtopiaapplication.cpp	2011-10-25 23:51:54.000000000 +0200
++++ qtmoko/src/libraries/qtopia/qtopiaapplication.cpp	2011-10-25 23:52:36.000000000 +0200
+@@ -1853,25 +1853,25 @@
+     QString dataDir(Qtopia::tempDir());
+     if ( mkdir( dataDir.toLatin1(), 0700 ) ) {
+         if ( errno != EEXIST ) {
+-            qFatal( QString("Cannot create Qt Extended data directory with permissions 0700: %1")
++            qFatal( "%s", QString("Cannot create Qt Extended data directory with permissions 0700: %1")
+                     .arg( dataDir ).toLatin1().constData() );
+         }
+     }
+ 
+     struct stat buf;
+     if ( lstat( dataDir.toLatin1(), &buf ) )
+-        qFatal( QString( "stat failed for Qtopia data directory: %1" )
++        qFatal( "%s", QString( "stat failed for Qtopia data directory: %1" )
+                 .arg( dataDir ).toLatin1().constData() );
+ 
+     if ( !S_ISDIR( buf.st_mode ) )
+-        qFatal( QString( "%1 is not a directory" ).arg( dataDir ).toLatin1().constData() );
++        qFatal( "%s", QString( "%1 is not a directory" ).arg( dataDir ).toLatin1().constData() );
+ 
+     if ( buf.st_uid != getuid() )
+-        qFatal( QString( "Qt Extended data directory is not owned by user %1: %2" )
++        qFatal( "%s", QString( "Qt Extended data directory is not owned by user %1: %2" )
+                 .arg( getuid() ).arg( dataDir ).toLatin1().constData() );
+ 
+     if ( (buf.st_mode & 0677) != 0600 )
+-        qFatal( QString( "Qt Extended data directory has incorrect permissions (expecting 0700): %1" )
++        qFatal( "%s", QString( "Qt Extended data directory has incorrect permissions (expecting 0700): %1" )
+                 .arg( dataDir ).toLatin1().constData() );
+ 
+     QPixmapCache::setCacheLimit(256);  // sensible default for smaller devices.
+Index: qtmoko/src/libraries/qtopia/qaudiosourceselector.cpp
+===================================================================
+--- qtmoko.orig/src/libraries/qtopia/qaudiosourceselector.cpp	2011-10-26 00:48:51.000000000 +0200
++++ qtmoko/src/libraries/qtopia/qaudiosourceselector.cpp	2011-10-26 00:49:19.000000000 +0200
+@@ -226,7 +226,7 @@
+         stream >> filename;
+         setContent( QContent( filename ) );
+     } else {
+-        qWarning( action.errorMessage().toLatin1() );
++        qWarning( "%s", action.errorMessage().toLatin1() );
+     }
+ }
+ 
+Index: qtmoko/src/libraries/qtopia/qimagesourceselector.cpp
+===================================================================
+--- qtmoko.orig/src/libraries/qtopia/qimagesourceselector.cpp	2011-10-26 00:50:17.000000000 +0200
++++ qtmoko/src/libraries/qtopia/qimagesourceselector.cpp	2011-10-26 00:50:31.000000000 +0200
+@@ -396,7 +396,7 @@
+             d->setLabel( stream );
+         }
+     } else {
+-        qWarning( action.errorMessage().toLatin1() );
++        qWarning( "%s", action.errorMessage().toLatin1() );
+     }
+ }
+ 
+Index: qtmoko/src/server/core_server/qcopfile.cpp
+===================================================================
+--- qtmoko.orig/src/server/core_server/qcopfile.cpp	2011-10-26 07:50:28.000000000 +0200
++++ qtmoko/src/server/core_server/qcopfile.cpp	2011-10-26 07:50:48.000000000 +0200
+@@ -52,13 +52,13 @@
+         fl.l_pid = getpid();
+         if (fcntl(qcopfile.handle(), F_SETLKW, &fl) == -1) {
+             /* some error occurred */
+-            qWarning(QString("Failed to obtain file lock on %1 (%2)")
++            qWarning("%s", QString("Failed to obtain file lock on %1 (%2)")
+                     .arg(qcopfn).arg( errno ).toAscii().constData());
+         }
+ #else
+         if(flock(qcopfile.handle(), LOCK_EX)) {
+             /* some error occurred */
+-            qWarning(QString("Failed to obtain file lock on %1 (%2)")
++            qWarning("%s", QString("Failed to obtain file lock on %1 (%2)")
+                     .arg(qcopfn).arg( errno ).toAscii().constData());
+         }
+ #endif
+@@ -77,7 +77,7 @@
+ 
+         return true;
+     } else {
+-        qWarning(QString("Failed to open file %1")
++        qWarning("%s", QString("Failed to open file %1")
+                 .arg(qcopfn).toAscii().constData());
+         return false;
+     }
+Index: qtmoko/src/server/ui/components/firstuse/firstuse.cpp
+===================================================================
+--- qtmoko.orig/src/server/ui/components/firstuse/firstuse.cpp	2011-10-26 13:49:18.000000000 +0200
++++ qtmoko/src/server/ui/components/firstuse/firstuse.cpp	2011-10-26 13:49:46.000000000 +0200
+@@ -418,7 +418,7 @@
+     config.beginGroup("Language");
+     QString l = config.value("Language", "en_US").toString();
+     QString cl = getenv("LANG");
+-    qWarning(QString("language message - %1").arg(l).toLatin1().constData());
++    qWarning("%s", QString("language message - %1").arg(l).toLatin1().constData());
+     // setting anyway...
+     if (l.isNull())
+         unsetenv("LANG");
+@@ -445,7 +445,7 @@
+         trans = new QTranslator(qApp);
+         QString atf = qmFiles[i];
+         QString tfn = Qtopia::qtopiaDir() + "i18n/"+l+"/"+atf;
+-        qWarning(QString("loading %1").arg(tfn).toLatin1().constData());
++        qWarning("%s", QString("loading %1").arg(tfn).toLatin1().constData());
+         if ( trans->load(tfn) ) {
+             qWarning(" installing translator");
+             qApp->installTranslator( trans );
+@@ -463,7 +463,7 @@
+             trans = new QTranslator(qApp);
+             QString atf = settingsTable[i].trans;
+             QString tfn = Qtopia::qtopiaDir() + "i18n/"+l+"/"+atf;
+-            qWarning(QString("loading %1").arg(tfn).toLatin1().constData());
++            qWarning("%s", QString("loading %1").arg(tfn).toLatin1().constData());
+             if ( trans->load(tfn) ) {
+                 qWarning(" installing translator");
+                 qApp->installTranslator( trans );
+Index: qtmoko/src/tools/dbmigrate/migrateengine.cpp
+===================================================================
+--- qtmoko.orig/src/tools/dbmigrate/migrateengine.cpp	2011-10-27 00:58:02.000000000 +0200
++++ qtmoko/src/tools/dbmigrate/migrateengine.cpp	2011-10-27 00:59:25.000000000 +0200
+@@ -54,7 +54,7 @@
+         QString errString=QString("CHECK: %1:%2 check failed: %3\n").arg(file).arg(line).arg(message);
+         db.rollback();
+         db.close();
+-        qCritical(qPrintable(errString));
++        qCritical("%s", qPrintable(errString));
+     }
+     return result;
+ }
+@@ -68,7 +68,7 @@
+         errString+=QString("SqlError: (%1, %2)\n").arg(query.lastError().number()).arg(query.lastError().text());
+         db.rollback();
+         db.close();
+-        qCritical(qPrintable(errString));
++        qCritical("%s", qPrintable(errString));
+         return false;
+     }
+     else
+@@ -85,7 +85,7 @@
+         errString+=QString("SqlError: (%1, %2, %3)\n").arg(qry.lastError().number()).arg(qry.lastError().databaseText()).arg(qry.lastError().driverText());
+         db.rollback();
+         db.close();
+-        qCritical(qPrintable(errString));
++        qCritical("%s", qPrintable(errString));
+         return false;
+     }
+     else
+@@ -280,7 +280,7 @@
+     if (!database->isOpen()) {
+         if (!database->open()) {
+             QString errString=QString("OPEN DATABASE: failed (%1, %2, %3)\n").arg(db.lastError().number()).arg(db.lastError().databaseText()).arg(db.lastError().driverText());
+-            qCritical(qPrintable(errString));
++            qCritical("%s", qPrintable(errString));
+             return false;
+         }
+     }
+@@ -320,7 +320,7 @@
+ 
+             if (!database->open()) {
+                 QString errString=QString("OPEN DATABASE: failed (%1, %2, %3)\n").arg(db.lastError().number()).arg(db.lastError().databaseText()).arg(db.lastError().driverText());
+-                qCritical(qPrintable(errString));
++                qCritical("%s", qPrintable(errString));
+                 return false;
+             }
+         }
+@@ -334,7 +334,7 @@
+     if (!database->transaction()) {
+         QString errString=QString("BEGIN TRANSACTION: failed (%1, %2, %3)\n").arg(database->lastError().number()).arg(database->lastError().databaseText()).arg(db.lastError().driverText());
+         db.close();
+-        qCritical(qPrintable(errString));
++        qCritical("%s", qPrintable(errString));
+         return false;
+     }
+ 
+@@ -519,7 +519,7 @@
+             QString errString=QString("COMMIT: failed (%1, %2, %3)\n").arg(db.lastError().number()).arg(db.lastError().databaseText()).arg(db.lastError().driverText());
+             db.rollback();
+             db.close();
+-            qCritical(qPrintable(errString));
++            qCritical("%s", qPrintable(errString));
+             return false;
+         }
+     }
+@@ -538,7 +538,7 @@
+         {
+             QString errString=QString("BEGIN TRANSACTION: failed (%1, %2, %3)\n").arg(db.lastError().number()).arg(db.lastError().databaseText()).arg(db.lastError().driverText());
+             db.close();
+-            qCritical(qPrintable(errString));
++            qCritical("%s", qPrintable(errString));
+             return false;
+         }
+ 
+@@ -553,7 +553,7 @@
+             QString errString=QString("COMMIT: failed (%1, %2, %3)\n").arg(db.lastError().number()).arg(db.lastError().databaseText()).arg(db.lastError().driverText());
+             db.rollback();
+             db.close();
+-            qCritical(qPrintable(errString));
++            qCritical("%s", qPrintable(errString));
+             return false;
+         }
+     }
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..c68439d
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+format-not-a-string-literal-and-no-format-arguments.patch
+alsa-scenarios.patch
diff --git a/debian/qtmoko-doc.debhelper.log b/debian/qtmoko-doc.debhelper.log
deleted file mode 100644
index 8b7c4a2..0000000
--- a/debian/qtmoko-doc.debhelper.log
+++ /dev/null
@@ -1,2 +0,0 @@
-dh_gencontrol
-dh_gencontrol
diff --git a/debian/qtmoko.install b/debian/qtmoko.install
new file mode 100644
index 0000000..df06966
--- /dev/null
+++ b/debian/qtmoko.install
@@ -0,0 +1 @@
+debian/tmp/opt/qtmoko
diff --git a/debian/qtmoko.links b/debian/qtmoko.links
new file mode 100644
index 0000000..557b527
--- /dev/null
+++ b/debian/qtmoko.links
@@ -0,0 +1,2 @@
+opt/qtmoko/lib/libQtScript.so.4.5.3 opt/qtmoko/lib/libQtScript.so.4.5
+opt/qtmoko/lib/libQtScript.so.4.5.3 opt/qtmoko/lib/libQtScript.so.4
diff --git a/debian/qtmoko.substvars b/debian/qtmoko.substvars
deleted file mode 100644
index abd3ebe..0000000
--- a/debian/qtmoko.substvars
+++ /dev/null
@@ -1 +0,0 @@
-misc:Depends=
diff --git a/debian/rules b/debian/rules
index 972ccd3..5123c86 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,22 +1,62 @@
 #!/usr/bin/make -f
 
-CONFIGURE = $(PWD)/configure
+ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+CC=$(DEB_HOST_GNU_TYPE)-gcc
+CXX=$(DEB_HOST_GNU_TYPE)-g++
+CROSS_CPPFLAGS=-I/usr/$(DEB_HOST_GNU_TYPE)/include/$(DEB_HOST_GNU_TYPE)
+CROSS_INCDIR=/usr/$(DEB_HOST_GNU_TYPE)/include /usr/$(DEB_HOST_GNU_TYPE)/include/$(DEB_HOST_GNU_TYPE) /usr/$(DEB_HOST_GNU_TYPE)/include/dbus-1.0 /usr/$(DEB_HOST_GNU_TYPE)/lib/dbus-1.0/include
+CROSS_LDFLAGS=
+CROSS_LIBDIR=/usr/$(DEB_HOST_GNU_TYPE)/lib
+else
+CC=gcc
+CXX=g++
+CROSS_CPPFLAGS=
+CROSS_INCDIR=/usr/include/dbus-1.0 /usr/lib/dbus-1.0/include
+CROSS_LDFLAGS=
+CROSS_LIBDIR=
+endif
 
-build:
+ifeq (arm-linux-gnueabi,$(DEB_HOST_GNU_TYPE))
+CROSS_CPPFLAGS+=-march=armv4t
+ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+CROSS_CPPFLAGS+=-fomit-frame-pointer -finline-functions -falign-functions=2 -falign-loops=2 -falign-jumps=2 -mtune=arm920t -msoft-float
+endif
+endif
+
+CFLAGS=$(shell dpkg-buildflags --get CFLAGS) $(CROSS_CPPFLAGS)
+CXXFLAGS=$(shell dpkg-buildflags --get CXXFLAGS) $(CROSS_CPPFLAGS)
+LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS) $(CROSS_LDFLAGS)
+
+CONFIGURE = $(CURDIR)/configure
+LANGUAGES = cs_CZ,en_US,it_IT,ru_RU,de_DE,es_ES,pl_PL,da_DK,fr_FR
+
+%:
+	dh $@
+
+override_dh_auto_configure:
+	cp -r debian/linux-debian-g++ devices/neo/mkspecs/qws/
+	sed -i "s:@CROSS_CC@:$(CC):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_CXX@:$(CXX):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_CFLAGS@:$(CFLAGS):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_CXXFLAGS@:$(CXXFLAGS):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_INCDIR@:$(CROSS_INCDIR):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_LDFLAGS@:$(LDFLAGS):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
+	sed -i "s:@CROSS_LIBDIR@:$(CROSS_LIBDIR):" devices/neo/mkspecs/qws/linux-debian-g++/qmake.conf
 	mkdir -p ../build
-	cd ../build && "$(CONFIGURE)" -device neo -xplatform linux-native-g++ -remove-module pkgmanagement -languages cs_CZ,en_US,it_IT,ru_RU,de_DE,es_ES,pl_PL,da_DK,fr_FR -l dbus-1 -I /usr/include/dbus-1.0/ -I /usr/lib/dbus-1.0/include
+	cd ../build && "$(CONFIGURE)" -extra-qt-embedded-config "-opensource" -device neo -xplatform linux-debian-g++ -remove-module pkgmanagement -languages $(LANGUAGES) -l dbus-1 -I /usr/include/dbus-1.0/ -I /usr/lib/dbus-1.0/include
+
+override_dh_auto_build:
 	cd ../build && make
 
-clean:
-	rm -rf debian/tmp
-	rm -f debian/files
+override_dh_auto_clean:
+	rm -fr ../build
+	rm -fr devices/neo/mkspecs/qws/linux-debian-g++
+	rm -f sdk/LICENSE.QtopiaGPL
 
-binary: build
+override_dh_auto_install:
 	cd ../build && make install
 	mkdir -p debian/tmp/opt/qtmoko
 	cp -r ../build/image/* debian/tmp/opt/qtmoko
-	rm -rf /tmp/qtmoko
-	mv ../build /tmp/qtmoko
 
 	# remove patented stuff - can be installed via package later
 	rm -f debian/tmp/opt/qtmoko/plugins/codecs/libmadplugin.so
@@ -26,10 +66,15 @@ binary: build
 	rm -rf debian/tmp/opt/qtmoko/lib/fonts
 	ln -s /usr/share/fonts/truetype/ttf-dejavu/ debian/tmp/opt/qtmoko/lib/fonts
 
-	install -d debian/tmp/DEBIAN
-	dpkg-gencontrol
-	dh_installdeb -P debian/tmp
-	dh_installinit -P debian/tmp
-	chown -R root:root debian/tmp/opt
-	chmod -R u+w,go=rX debian/tmp/opt
-	dpkg --build debian/tmp ..
+	# Install missing dependency for qt_plugins/script/libqtscriptdbus.so
+	install -m"a+r,u+w" ../build/qtopiacore/target/lib/libQtScript.so.4.5.3 debian/tmp/opt/qtmoko/lib
+
+	# Alsa scenarios
+	mkdir -p debian/tmp/opt/qtmoko/etc/alsa-scenarios
+	install -m"a+r,u+w" devices/neo/alsa_scenarios/gta02_2.6.32/*.state debian/tmp/opt/qtmoko/etc/alsa-scenarios
+
+override_dh_makeshlibs:
+	dh_makeshlibs -n
+
+override_dh_shlibdeps:
+	dh_shlibdeps -l$(CURDIR)/debian/qtmoko/opt/qtmoko/lib
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
